package cn.edu.qvtu.rj231.lms04;


import cn.edu.qvtu.rj231.lms01.Callback;
import cn.edu.qvtu.rj231.lms01.Employee;
import cn.edu.qvtu.rj231.lms03.EmployeeService;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
//1.用表单提交请求（会导致页面跳转，通常一个页面中，会嵌入很多个子页面）
//2.AJAX提交请求（ 以后都使用这种方案，实现页面分离）

@RestController
@RequestMapping("/emp")
public class EmployeeController {
    @Autowired
    private EmployeeService service;
    private long id;
    private  String name;
    private  int age;
    private  double salary;
    //D:\pthouge\javaWeb\rj231/pom.xml
    //D:\pthouge\javaWeb\rj231.zip
    //http://localhost:8080/emp/add.do
    //http://localhost:8080/employee.html
    @RequestMapping("add.do") //get/post
    public Callback add(Employee emp){
        return service.add(emp);
    }
    //http://localhost:8080/emp/setAll.do
    @RequestMapping("setAll.do")
    public Callback setAll(){
        return service.setAll();
    }
    @RequestMapping("del.do")
    public Callback del(long id){
        return service.del(id);
    }
}
